let model = require('../../model/base')
let fs = require('fs');
var Index = {
    index: async function (req,res) {
        let date = req.query['date'];
        let sql = 'select * from yiqing where date=?';
        console.log(req.query);
        // model.select(sql, date);
        let result = await model.select(sql, date);
        let html = '';
        for (let val in result) {
            html += '<tr>';
            console.log(result[val].city);
            console.log(result[val].nums);
            html += '<td>' + result[val].city + '</td>';
            html += '<td>' + result[val].nums + '</td>';
            html += '<td>' + result[val].date + '</td>';
            html += '</tr>';
        }
        console.log(html);
        let bf = fs.readFileSync('./home/html/demo.html');
        let output = bf.toString();
        let str = output.replace('{{result}}',html);
        res.end(str)
    }
}
module.exports = Index;